package com.mybatis.demo.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

import java.sql.Connection;

@Component
@Aspect
//拦截DataSource.getConnection方法，生成自定义MyConnection
public class ConnectionAnnotationHandle {
    @Around("execution(* javax.sql.DataSource.getConnection(..))")
    public Connection around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        Connection proceed =(Connection) proceedingJoinPoint.proceed();
        return new MyConnection(proceed);
    }
}
